-
Notifications
You must be signed in to change notification settings - Fork 547
array_rand() requires a non-empty-array as of php8 #4397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
it even requires a positve $num arg as of php8, see https://3v4l.org/b53OZ |
| 'iterator_count' => ['0|positive-int', 'iterator'=>'iterable'], | ||
| 'iterator_to_array' => ['array', 'iterator'=>'iterable', 'use_keys='=>'bool'], | ||
| 'str_split' => ['list<string>', 'str'=>'string', 'split_length='=>'positive-int'], | ||
| 'Random\Randomizer::pickArrayKeys' => ['non-empty-array<int|string>', 'array'=>'non-empty-array', 'num'=>'positive-int'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure whether/how this signature should be behind bleeding edge but beeing php 8.2+ at the same time.
as the api is pretty recent and throws runtime errors when used with empty array or non-positive-int its acceptable to enforce this more strict signature even in non-bleeding edge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in this case it's okay 👍
|
This pull request has been marked as ready for review. |
|
Thank you! |
see https://3v4l.org/sEB2j
we did not error before this PR: https://phpstan.org/r/2f650341-3dc9-4849-9cac-2bd267a7fb41